import os
import json


def classDictWriter(path: str, class_dict: dict) -> bool:
    if not os.path.isdir(path):
        print("{} is not a dir!".format(path))
        return False
    else:
        class_dict = dict((val, key) for key, val in class_dict.items())  # 类别字典--'数字': '类别名'
        json_str = json.dumps(class_dict, indent=4)
        with open(os.path.join(path, "class_indices.json"), 'w') as f:
            f.write(json_str)
        return True
